package com.hnkywl.sts.action.zjgl;

import com.hnkywl.sts.entity.djgl.Jydd;
import com.hnkywl.sts.entity.sys.Gncz;
import com.hnkywl.sts.entity.zjgl.Hthk;
import com.hnkywl.sts.entity.zjgl.Jzjs;
import com.hnkywl.sts.service.sys.GnczService;
import com.hnkywl.sts.service.zjgl.HthkService;
import com.hnkywl.sts.service.zjgl.JzjsService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by HL on 2016/4/12.
 */
@Namespace("/zjgl/jzjs")
public class JzjsAction extends SimpleActionSupport {

    private int page;
    //分页组件 页面大小
    private int rows = 10;
    //功能操作
    private List<Gncz> gnczList;
    private GnczService gnczService;
    private JzjsService jzjsService;

    private String htbm;

    private Jydd jydd;


    private Long gsId;
    private String khMc;
    private String hth;
    private Jzjs jzjs;
    private Long jzjsid;
    // 合同货款分页显示
    @Action("jzjsList")
    public void jzjsList() {
        this.renderJson(this.jzjsService.findAlljzjs(gsId, khMc, hth, page, rows));
    }

    // 弹出新增页面
    @Action("jzjs_content")
    public String jzjs_content() {
        jzjs = new Jzjs();
        return SUCCESS;
    }


    /**
     * 增加合同货款
     */
    @Action("add_jzjs")
    public void add_jzjs() {
        try {
            this.jzjsService.saveJzjs(jzjs);
            renderText("{\"statusCode\":\"200\", \"message\":\"添加成功！\", \"operationType\":\"add\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }

    @Action("tj_jzjs")
    public void tj_jzjs() {
        try {
            this.jzjsService.tjJzjs(jzjsid);
            renderText("{\"statusCode\":\"200\", \"message\":\"提交成功！\", \"operationType\":\"add\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }



    @Action("delete_jzjs")
    public void deletejzjs() {
        try {
            this.jzjsService.deletejzjs(jzjsid);
            renderText("{\"statusCode\":\"200\", \"message\":\"删除成功！\", \"operationType\":\"delete\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }
    //==================================

    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    public String getKhMc() {
        return khMc;
    }

    public void setKhMc(String khMc) {
        this.khMc = khMc;
    }

    public String getHth() {
        return hth;
    }

    public void setHth(String hth) {
        this.hth = hth;
    }

    public Jzjs getJzjs() {
        return jzjs;
    }

    public void setJzjs(Jzjs jzjs) {
        this.jzjs = jzjs;
    }

    public Long getJzjsid() {
        return jzjsid;
    }

    public void setJzjsid(Long jzjsid) {
        this.jzjsid = jzjsid;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public List<Gncz> getGnczList() {
        return gnczList;
    }

    public void setGnczList(List<Gncz> gnczList) {
        this.gnczList = gnczList;
    }

    public String getHtbm() {
        return htbm;
    }

    public void setHtbm(String htbm) {
        this.htbm = htbm;
    }

    @Autowired

    public void setJzjsService(JzjsService jzjsService) {
        this.jzjsService = jzjsService;
    }
    @Autowired
    public void setGnczService(GnczService gnczService) {
        this.gnczService = gnczService;
    }
}
